package com.rivulet.doj_backend.controller;

import com.rivulet.doj_backend.service.ClassService;
import com.rivulet.doj_backend.tools.ResultFul;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@CrossOrigin(origins = {"http://localhost:8080", "null"})
@RestController
@RequestMapping(value = "/doj")
public class ClassController {
    @Autowired
    ClassService classService;

    @RequestMapping(value = ("/class/{class_id}/join/{user_id}"),method = RequestMethod.POST)
    public ResultFul setUserJoinClass(@PathVariable Integer class_id,@PathVariable Integer user_id) {
        return classService.setUserJoinClass(user_id,class_id);
    }

    @RequestMapping(value = ("/user/{user_id}/class"),method = RequestMethod.POST)
    public ResultFul inquiryClass(@PathVariable Integer user_id) {
        return classService.inquiryClass(user_id);
    }

    @RequestMapping(value = ("/user/{user_id}/class/{class_id}"),method = RequestMethod.POST)
    public ResultFul showClass(@PathVariable Integer user_id,@PathVariable Integer class_id) {
        return classService.showClass(user_id,class_id);
    }

    @RequestMapping(value = ("/class/{user_id}/{class_id}"),method = RequestMethod.POST)
    public ResultFul delClass(@PathVariable Integer user_id,@PathVariable Integer class_id) {
        return classService.delClass(user_id,class_id);
    }

    @RequestMapping(value = ("/user/{user_id}/task"),method = RequestMethod.POST)
    public ResultFul showTask(@PathVariable Integer user_id) {
        return classService.showTask(user_id);
    }

    @RequestMapping(value = ("/user/{user_id}/class/{class_id}/number"),method = RequestMethod.POST)
    public ResultFul delUser(@PathVariable Integer user_id,@PathVariable Integer class_id) {
        return classService.delUser(user_id,class_id);
    }

    @RequestMapping(value = {"/task/{user_id}"}, method = RequestMethod.POST)
    public ResultFul addTask(@PathVariable Integer user_id, Integer task_id, Integer question_number, int question_ids, Integer question_score, String task_explain, Integer relation_class_id) {
        return this.classService.addTask(user_id, task_id, question_number, question_ids, question_score, task_explain, relation_class_id);
    }

    @RequestMapping(value = {"/class/{user_id}"}, method = {RequestMethod.POST})
    public ResultFul addClass(@PathVariable Integer user_id, Integer class_id, String class_root, Integer task_number, Integer user_number, Integer creat_time, Integer class_level) {
        return this.classService.addClass(user_id, class_id, class_root, task_number, user_number, creat_time, class_level);
    }

    @RequestMapping(value = {"/class/{class_id}/number"}, method = {RequestMethod.POST})
    public ResultFul showPeopleNumber(@PathVariable Integer class_id) {
        return this.classService.showPeopleNumber(class_id);
    }
    
}
